//
//  DCFNetworkManager.h
//  DCF
//
//  Created by 吴文拼 on 2017/12/26.
//  Copyright © 2017年 吴文拼. All rights reserved.
//

#import <Foundation/Foundation.h>

@class DCFResponseModel;

typedef void (^DCFNetworkSuccessHandler)(DCFResponseModel *response);
typedef void (^DCFNetworkFailHandler)(NSError *error);

@interface DCFNetworkManager : NSObject

+ (void)postDCFTo:(NSString *)url withJSON:(id)parameters successHandler:(DCFNetworkSuccessHandler)successHandler failHandler:(DCFNetworkFailHandler)failHandler;

+ (void)deleteDCF:(NSString *)url withJSON:(id)parameters successHandler:(DCFNetworkSuccessHandler)successHandler failHandler:(DCFNetworkFailHandler)failHandler;

+ (void)fetchDCFJSONFrom:(NSString *)url successHandler:(DCFNetworkSuccessHandler)successHandler failHandler:(DCFNetworkFailHandler)failHandler;

+ (void)putDCFTo:(NSString *)url withJSON:(id)parameters successHandler:(DCFNetworkSuccessHandler)successHandler failHandler:(DCFNetworkFailHandler)failHandler;

//控制时限的get请求
+ (void)fetchDCFJSONFrom:(NSString *)url withTimeoutInterval:(NSInteger)time successHandler:(DCFNetworkSuccessHandler)successHandler failHandler:(DCFNetworkFailHandler)failHandler;

//上传表单数据
+ (void)postDCFTo:(NSString *)url withJSON:(id)parameters uploadDataArr:(NSArray *)dataArr successHandler:(DCFNetworkSuccessHandler)successHandler failHandler:(DCFNetworkFailHandler)failHandler;

//设置公用请求头
+(void)giveHTTPRequestHeader:(NSMutableURLRequest *)needRequest;

//获取请求头内容
+(NSDictionary *)getHeaderDic;

@end

@interface DCFResponseModel : NSObject

@property (nonatomic , assign)NSInteger statusCode;
@property (nonatomic , strong)id responseData;
@property (nonatomic ,   copy)NSString *message;
@property (nonatomic , assign)BOOL success;
@property (nonatomic , strong)NSDictionary *originalData;

-(instancetype)initWithResponse:(NSDictionary *)response;

@end

@interface DCFNetworkUploadDataModel : NSObject

@property (nonatomic , strong)NSData *fileData;
@property (nonatomic ,   copy)NSString *name;
@property (nonatomic ,   copy)NSString *fileName;
@property (nonatomic ,   copy)NSString *mimeType;

@end

